// Copyright 2012 Google Inc. All Rights Reserved.

package com.google.appengine.preferencessync.internal;

/**
 * Sync exception thrown by the client.
 */
@SuppressWarnings("serial")
public class InternalSyncException extends Exception {

  public static final String USERNAME_NAME_NOT_SET = "Username not set";
  public static final String URL_NOT_SET = "Server URL not set";

  /**
   * Type of the exception.
   */
  public enum ExceptionType {

    // HttpStatus == CONFLICT
    INTERNAL_HTTP_STATUS_CONFLICT,
    
    // Connection timed out  
    INTERNAL_HTTP_TIMEOUT,
    
    // Some other internal exception.
    INTERNAL_EXCEPTION;
  }

  private final ExceptionType type;

  // Severity as in Severity in android.util.Log
  private final int severity;

  /**
   * @param type
   * @param message
   * @param severity as in {@link android.util.Log}.
   */
  public InternalSyncException(ExceptionType type, String message, int severity) {
    super(message);
    this.type = type;
    this.severity = severity;
  }

  /**
   * @param e {@link java.lang.Throwable} which cause the internal exception.
   * @param type
   * @param message
   * @param severity as in {@link android.util.Log}.
   */
  public InternalSyncException(Throwable e, ExceptionType type, String message, int severity) {
    super(message, e);
    this.type = type;
    this.severity = severity;
  }

  /**
   * @return The type of the exception.
   */
  public ExceptionType getType() {
    return type;
  }

  /**
   * @return Get the severity of the exception.
   */
  public int getSeverity() {
    return severity;
  }
}
